package com.hdaccp.shuiguoD.controller;


import com.hdaccp.shuiguoD.entity.Yuangong;
import com.hdaccp.shuiguoD.service.yuangongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/yuangong")
@Scope("prototype")
public class yuangongController {

    @Autowired
    private yuangongService yuangongService;

    @RequestMapping("/queryAll")
    @ResponseBody
    public Map<String,Object> queryAll(int offset, int limit){
        /* Map<String,Object> map = new HashMap<>() ;
        map.put("rows",userInfoService.findAll(offset,limit)) ;
        map.put("total",userInfoService.findTotalCount()) ;
        return  map ;*/

        return null;
    }

    /*  @RequestMapping("/queryAll")
      @ResponseBody
      public List<Kehu> queryAll(){

          return kehuService.getAll();

      }
  */
    @RequestMapping("/querySearch")
    @ResponseBody
    public Map<String,Object> querySearch(String yname, int offset, int limit){
        Map<String,Object> map = new HashMap<>();
        map.put("rows",yuangongService.findAll(yname,offset,limit));
        map.put("total",yuangongService.findTotalCount(yname));
        return map;
    }

    @RequestMapping("/shanchu")
    @ResponseBody
    public int shanchu(int yid){
        return yuangongService.delte(yid);
    }

    @RequestMapping("/inst")
    @ResponseBody
    public int inst(Yuangong yuangong){
        return yuangongService.zj(yuangong);
    }



    @RequestMapping("/xg")
    @ResponseBody
    public int xg(Yuangong yuangong){
        System.out.println(yuangong.getYid()+"---"+yuangong.getYname());
        return yuangongService.update(yuangong);
    }

    @RequestMapping("/queryById")
    @ResponseBody
    public Yuangong queryById(int yid){
        return yuangongService.queryById(yid);
    }
}

